home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / J-M / MenuUtils.cpt / Command History / card_2852.txt < prev    next >
Text File  |  1989-04-19  |  9KB  |  266 lines

  1. -- card: 2852 from stack: in
  2. -- bmap block id: 2180
  3. -- flags: 4000
  4. -- background id: 2592
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: 8003
  11. -- rect: left=165 top=135 right=157 bottom=357
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Install Command History
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   global temp
  23.   answer "This will modify your Home Stack!" with "Go Ahead" or "Cancel"
  24.   if it is "cancel" then exit mouseup
  25.   set the cursor to watch
  26.   put (long name of this stack) into sourceStack
  27.   delete first word of sourceStack
  28.   delete first character of sourceStack
  29.   delete last character of sourceStack
  30.   lock screen
  31.   put the script of cd button "command history scripts" into newscript
  32.   push card
  33.   go home
  34.   put the script of this stack into homescript
  35.   if homescript contains "setuphistory" then
  36.     answer "Command History already installed!" with "OK"
  37.     pop card
  38.     exit mouseup
  39.   end if
  40.   put (long name of this stack) into destStack
  41.   delete first word of destStack
  42.   delete first character of destStack
  43.   delete last character of destStack
  44.   pop card
  45.   rescopy sourceStack,destStack,"XFCN","DeleteMenu"
  46.   rescopy sourceStack,destStack,"XFCN","NewMenu"
  47.   rescopy sourceStack,destStack,"XCMD","ShowMenu"
  48.   rescopy sourceStack,destStack,"XCMD","EnableMenu"
  49.   rescopy sourceStack,destStack,"XCMD","ChangeMenu"
  50.   rescopy sourceStack,destStack,"XCMD","CheckMenu"
  51.   push card
  52.   go home
  53.   put return & return & newscript after homescript
  54.   put homescript into temp
  55.   put offset("on startup",homescript) into off
  56.   put ("on startup" & return & "setuphistory" & return) into char off to off+10 of homescript
  57.   set the script of this stack to homescript
  58.   startup
  59.   pop card
  60.   unlock screen
  61.   flash
  62. end mouseUp
  63.  
  64.  
  65.  
  66. -- part 3 (button)
  67. -- low flags: 80
  68. -- high flags: 8003
  69. -- rect: left=157 top=311 right=333 bottom=342
  70. -- title width / last selected line: 0
  71. -- icon id / first selected line: 0 / 0
  72. -- text alignment: 1
  73. -- font id: 0
  74. -- text size: 12
  75. -- style flags: 0
  76. -- line height: 16
  77. -- part name: Command History Scripts
  78. ----- HyperTalk script -----
  79. --Command History scripts ¬© 1989 by Steve Martin
  80. --Shareware fee of $10 should be sent to
  81. --Steve Martin
  82. --6632 Warm Breeze Lane
  83. --Dallas, TX  75248-5021
  84.  
  85. on arrowkey arrow
  86.   global msghistory, historyindex
  87.   if the optionkey is down then
  88.     if arrow is up then
  89.       add 1 to historyindex
  90.       put unquotify(line historyindex of msghistory) into com
  91.       if (the visible of msg) and (com is msg) then add 1 to historyindex
  92.       get the number of lines of msghistory
  93.       if historyindex > it then put 1 into historyindex
  94.       put unquotify(line historyindex of msghistory)
  95.     end if
  96.     if arrow is down then
  97.       subtract 1 from historyindex
  98.       get the number of lines of msghistory
  99.       if historyindex < 1 then put it into historyindex
  100.       put unquotify(line historyindex of msghistory)
  101.     end if
  102.   else pass arrowkey
  103. end arrowkey
  104.  
  105. on domenu which
  106.   global msghistory,history
  107.   if history is not empty then
  108.     repeat with x = 1 to history
  109.       if line x of msghistory is which then
  110.         put unquotify(which)
  111.         select empty
  112.         type return
  113.         exit domenu
  114.       end if
  115.     end repeat
  116.   end if
  117.   pass domenu
  118. end domenu
  119.  
  120. on idle
  121.   global msghistory, historyindex,historymenu,lasttick
  122.   if historyindex is not empty and historymenu is not empty then
  123.     if (the ticks-lasttick) > 120 then
  124.       put the ticks into lasttick
  125.       showmenu historymenu
  126.       if historyindex > 0 and line historyindex of msghistory <> quotify(msg) then
  127.         put 0 into historyindex
  128.       end if
  129.     end if
  130.   end if
  131.   pass idle
  132. end idle
  133.  
  134. on returnkey
  135.   global msghistory, historyindex, history,historymenu
  136.   if historymenu is not empty then
  137.     put quotify(the msg) into qmsg
  138.     if line 1 of msghistory <> qmsg then
  139.       put qmsg & return before msghistory
  140.       if history > 1 then
  141.         repeat with x = 2 to history
  142.           get line x of msghistory
  143.           if it is "none" then exit repeat
  144.           if it is qmsg then
  145.             delete line x of msghistory
  146.             exit repeat
  147.           end if
  148.         end repeat
  149.       end if
  150.       repeat with x = 1 to history
  151.         if line x of msghistory <> empty then
  152.           changemenu historymenu,x,line x of msghistory
  153.           enablemenu historymenu,x,true
  154.         else exit repeat
  155.       end repeat
  156.     end if
  157.     if the number of lines of msghistory > history then
  158.       delete last line of msghistory
  159.     end if
  160.     put 0 into historyindex
  161.   end if
  162.   pass returnkey
  163. end returnkey
  164.  
  165. on setuphistory
  166.   global historyindex,history,historymenu
  167.   put 0 into historyindex
  168.   put 15 into history
  169.   repeat with x = 1 to history
  170.     put "none" into line x of temp
  171.   end repeat
  172.   if historymenu is empty then
  173.     put newmenu("History",temp) into historymenu
  174.     repeat with x = 1 to history
  175.       enablemenu historymenu,x,false
  176.     end repeat
  177.   end if
  178. end setuphistory
  179.  
  180. function quotify string
  181. put quote into q
  182. get offset(q,string)
  183. repeat while it > 0
  184.   put "''" into char it of string
  185.   get offset(q,string)
  186. end repeat
  187. return string
  188. end quotify
  189.  
  190. function unquotify string
  191. put "''" into q
  192. get offset(q,string)
  193. repeat while it > 0
  194.   put quote into char it to it+1 of string
  195.   get offset(q,string)
  196. end repeat
  197. return string
  198. end unquotify
  199.  
  200. --End of Command History Scripts
  201.  
  202.  
  203.  
  204. -- part 5 (field)
  205. -- low flags: 00
  206. -- high flags: 0007
  207. -- rect: left=0 top=163 right=293 bottom=512
  208. -- title width / last selected line: 0
  209. -- icon id / first selected line: 0 / 0
  210. -- text alignment: 0
  211. -- font id: 3
  212. -- text size: 12
  213. -- style flags: 0
  214. -- line height: 16
  215. -- part name: Command History Help
  216.  
  217.  
  218. -- part contents for card part 5
  219. ----- text -----
  220. This stack may be freely distributed, but the HyperTalk scripts are ¬©1989 by Steve Martin and may not be sold for profit without my expressed written permission.
  221.  
  222. Do you type messages into the message box?  Do you hate to retype long hypertalk commands over and over again?  If you do, this is for you.
  223.  
  224. Command History for Hypercard gives you the ability to recall recently typed messages to the message box, or execute them from a menu.
  225.  
  226. The best way to understand it is to try it so...
  227.  
  228. Type "flash" into the message box and type return.
  229. Now look in the "History" menu in the menu bar.  If you pull it down, you will see the command "flash" in the first line.  Select it to execute "flash" again.
  230.  
  231. Now type "beep" into the message box.  The "History" menu now has two items, "beep" and "flash".  Select whichever you want to execute it.
  232.  
  233. Next, try out the keyboard part.  If you hold down the option key and type the up or down arrows, you can cycle through the last 15 commands you have typed into the message box.  Try it now and you will alternate between "flash" and "beep".  They will not be executed until you press return.
  234.  
  235. Now that you've tried it (and liked it I'm sure!), you will probably want to install it into your home stack so that you can use it all the time.
  236.  
  237. First of all, go to the Home stack and SAVE A COPY.  The installation procedure adds new XCMDs and XFCNs and modifies the stack script of your Home stack.  If something goes wrong, you want to have a backup!
  238.  
  239. If you have extensively modified your Home Stack scripts, you should read the technical notes below.  Otherwise, click on the "Install Command History" button and when the screen flashes, you are done!
  240.  
  241. If you use it, please send the $10 Shareware fee to:
  242. Steve Martin
  243. 6632 Warm Breeze Lane
  244. Dallas, TX  75248-5021
  245.  
  246. If you have comments or questions please contact me!  I can be reached electronically as follows:
  247. Compuserve: 72727,1471
  248. Genie: S.MARTIN8
  249. Arpanet: SMARTIN@CSC.TI.COM
  250.  
  251. Also, look for my chapter on Large Stacks in Tricks of the HyperTalk Masters, an upcoming  Hayden "Macintosh Library" Book, edited by The Waite Group.
  252.  
  253. Technical Notes
  254. --------------
  255.  
  256. Command History adds the following scripts to your home stack, ArrowKey, DoMenu, Idle, and ReturnKey.  If they are already there, you will have to do some script hacking to install the new ones.  The easiest way to do this would be to install them as normal and then edit your stack script, renameing the new handlers (CHArrowKey,CHDoMenu, or something like that)  and then calling them at the beginning of your own handlers.
  257.  
  258. Special thanks to:
  259. Nine to Five Software Company
  260. P.O. Box 915
  261. Greenwood, IN  46142
  262. (317) 887-2154
  263. & Michael Long
  264. for the Menu management XCMDs and XFCNs.
  265.  
  266. Special thanks also to Alan Josephson and Fred Hollander for beta testing and to my wife Carolyn who wanted a word processor (so I got a Mac II of course!)